import org.hibernate.Session;
import org.hibernate.Transaction;

import com.guhappy.util.HibernateUtil;

public class Test {
	public static void main(String[] args) {
		add();
		System.out.println();
	}

	static void add() {
		Session s = null;
		Transaction tx = null;
		try {
			// Department depart = new Department();
			// depart.setName("department name");
			Employee employee = new Employee();
			// employee.setDepartment(depart); // 对象模型：建立两个对象的关联
			employee.setName("employee name");
			s = HibernateUtil.getSessionFactory().openSession();
			tx = s.beginTransaction();
			// s.save(depart);
			s.save(employee);
			tx.commit();
			// return depart;
		} finally {
			if (s != null)
				s.close();
		}
	}
}